package com.newtouch.xcd.pms.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.newtouch.xcd.config.entity.AdminAccountPhoneConfig;
import com.newtouch.xcd.pms.config.AdminAccountPhoneConfigs;
import com.newtouch.xcd.pms.service.AdminAccountPhoneConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Service
public class AdminAccountPhoneConfigServiceImpl implements AdminAccountPhoneConfigService {

    @Autowired
    AdminAccountPhoneConfigs adminAccountPhoneConfigs;

    @Override
    public List<AdminAccountPhoneConfig> allConfig() {
        return this.adminAccountPhoneConfigs.getConfigs();
    }

    @Override
    public AdminAccountPhoneConfig queryByPhone(String phone) {

        for(AdminAccountPhoneConfig config:adminAccountPhoneConfigs.getConfigs()){
            if(phone.equals(config.getPhone())){
                return config;
            }
        }

        return null;
    }

    @Override
    public String getSmsCode() {
        return this.adminAccountPhoneConfigs.getSmsCode();
    }
}
